import axios from "axios" /* 引入axios */
import store from "../store";
let {
    token
} = store.state.userInfo
console.log(token);
const http = axios.create({
    baseURL: " https://apipc-xiaotuxian-front.itheima.net/"
        /*
           https://apipc-xiaotuxian-front.itheima.net/ 请求公用地址
           https://pcapi-xiaotuxian-front-devtest.itheima.net */
        ,

    timeout: 5000 /* 超时 */ ,
})
http.interceptors.request.use(function (config) {
    if (token) {
        config.headers.Authorization = `Bearer ${token}`
    }
    return config;
}, function (error) {
    return Promise.reject(error);
});
http.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    return Promise.reject(error);
});
export default http